package com.icinfo.cloud.provider.peripheralinterface.healthcare.controller;

import cn.hutool.core.util.ObjectUtil;
import com.icinfo.cloud.provider.peripheralinterface.healthcare.dto.HealthCareFileSealInfoQueryDto;
import com.icinfo.cloud.provider.punish.common.seal.service.IFileSealProvinceUnifiedService;
import com.icinfo.framework.common.web.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 描述：卫健委接口前端控制器
 * @author shishengyao
 * @description
 * @date 2023/3/13
 */
@RestController
@RequestMapping("/peripheralInterface/healthCare")
@Slf4j
@RefreshScope
public class HealthCareController {

    @Resource
    private IFileSealProvinceUnifiedService fileSealProvinceUnifiedService;
    /**
     * 【V1.11.1】描述：卫健委文件签章接口
     *
     * @param queryDto 查询dto
     * @return {@link Result<Map<String, Object>> }
     * @author shishengyao
     * @date 2023/03/13
     */
    @PostMapping("/sealFile")
    @ApiOperation(value = "【V1.3.0】描述：文件签章接口", httpMethod = "POST")
    public Result<Map<String, Object>> sealFile( @Validated HealthCareFileSealInfoQueryDto queryDto) {
        if (ObjectUtil.isEmpty(queryDto.getSealCode())){
            queryDto.setSealCode("");
        }
        log.info("卫健委文件签章，请求参数：{}",queryDto);
         Map<String, Object> fileAfterSeal = fileSealProvinceUnifiedService.getFileAfterSeal(queryDto);
        if (ObjectUtil.isNotEmpty(fileAfterSeal.get("errorMsg"))) {
            return Result.error(fileAfterSeal.get("errorMsg").toString());
        }
        return Result.success(fileAfterSeal);
    }
}
